import RequestUtils from '@/utils/RequestUtils'

const groupName = 'system'
const apiName = 'role'

export default {
  add(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  remove(id) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/${id}`,
      method: 'DELETE'
    })
  },
  edit(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  updateRoleMenus(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/roleMenus`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  updateDataScope(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/dataScope`,
      method: 'PUT',
      data: {
        ...params
      }
    })
  },
  get(id) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/${id}`,
      method: 'GET'
    })
  },
  list(params = {}) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/search`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  page(params = {}, page) {
    return RequestUtils({
      url: `/${groupName}/${apiName}/search/${page.current}/${page.pageSize}`,
      method: 'POST',
      data: {
        ...params
      }
    })
  },
  options() {
    return RequestUtils({
      url: `/${groupName}/${apiName}/search/options`,
      method: 'POST'
    })
  }
}
